﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using PingYou.ADO;

namespace PingYou.Api.UI
{
    public class DemoController : ApiController
    {
        #region 查询用户相关数据
        [HttpGet]
        public dynamic GetTest()
        {
            BaseDBCon myBaseDBCon = new BaseDBCon();
            try
            {
                //myBaseDBCon.Open()
                string str = @"
                select
                  ID,
                  IsEnabled    ,  
                  IsLocked      , 
                  LastLoginDate  ,
                  LastLoginIp    ,
                  LockDate       ,
                  Remark         ,
                  Enabled        ,
                  CreateStaff   ,
                  CreateDate     ,
                  ModifyStaff   ,
                  ModifyDate     
                from SYS_User WHERE Enabled=1 ";
                DataTable myDt = new DataTable();
                myBaseDBCon.Fill(str, myDt);

                if (myDt.Rows.Count > 0)
                {
                    return new
                    {
                        success = true,
                        data = new
                        {
                            d1 = myDt.Rows[0]["ID"].ToString()
                        }
                    };
                }
                else
                {
                    return new
                    {
                        success = true,
                        data = new
                        {
                            d1 = ""
                        }
                    };
                }

            }
            catch (Exception myEx)
            {
                Common.WriteLogErr("GetTest：" + myEx.Message);
                return new { success = false, Message = myEx.Message };
            }
        }
        #endregion
    }
}